using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "Data/State/Player/PlayerAirJump", fileName = "PlayerAirJump")]
public class PlayerState_AirJump : PlayerState
{
    [SerializeField] private float playerAirJumpSpeed;
    //
    public override void Enter()
    {
        base.Enter();
        AudioManager.Instance.PlayAudioSourceSFX(AudioSFXPath.PLAYER_JUMP, stateMachine.gameObject);
        playerDetection.IsCanAirJumo = false;
        playerControl.SetVelocityY(playerAirJumpSpeed);
    }
    
    //
    public override void Exit()
    {
        base.Exit();
    }
    
    //
    public override void LogicUpdate()
    {
        base.LogicUpdate();
        if ((my_Body2D.velocity.y <= 0 || playerInput.isInputStopJump) && !playerDetection.GetIsGround)
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_Fall)]);
        // 状态
        if(playerStatusInformation.IsFly)
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_Fly)]);
        if(playerStatusInformation.PlayerIsHit)
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_Hit)]);
        if(playerStatusInformation.GetPlayerIsDeath)
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_Death)]);
    }
    
    //
    public override void PhysicalUpdate()
    {
        base.PhysicalUpdate();
        animator.SetFloat("Horizontal", playerInput.axesX);
    }
}
